#include "event_manager.h"
namespace TinyRPC{

EventManager& EventManager::GetInstance(){
    static EventManager eventManager;
    return eventManager;
}
void EventManager::addEventPtr(EventPtr event){
    m_eventMap[event->getFd()] = std::weak_ptr<Event>(event);
}

EventPtr EventManager::getEventPtr(int fd){
    return m_eventMap[fd].lock();
}


void EventManager::delEventPtr(int fd){
        auto it = m_eventMap.find(fd);
        if(it != m_eventMap.end()){
            m_eventMap.erase(it);
        }
    }

std::unordered_map<int, std::weak_ptr<Event>> EventManager::m_eventMap;

}
